import React, { Component } from 'react';
import CustomForm from '../../../components/CustomForm';
import { Input } from 'antd';
const { TextArea } = Input;

class Remark extends Component {
  constructor(props) {
    super(props);
    this.form = null;
    this.api = 'audit';
    this.inputRef = null
  }

  componentDidMount() {
    this.inputRef.focus()
  }

  handleSubmit = () => {
    this.form.validateFields((err, values) => {
      if (!err) {
        this.props.updateStatus(this.props.status, values.audit_remark)
      }
    });
  };

  render() {
    const formItems = [
      {
        label: {
          label: '审核意见',
          className: 'tantuer-form-item1 tantuer-form-item-nowrap'
        },
        name: 'audit_remark',
        span: 24,
        options: {
          initialValue: '',
          rules: [
            { required: true, message: '请输入审核意见' },
            { max: 256, message: '最长256个字符' },
            { pattern: /[\S]+/, message: '请输入审核意见' },
          ]
        },
        component: <TextArea rows={4} placeholder='请填写' ref={input => this.inputRef = input} />
      }
    ];

    return (
      <CustomForm
        colNum={1}
        closeModal={() => this.props.closeModal(true)}
        createForm={ref => (this.form = ref)}
        formItems={formItems}
        onHandleSubmit={this.handleSubmit}
      />
    );
  }
}

export default Remark;
